import type { FieldRule } from 'vant'

const mobileRules: FieldRule[] = [
  {
    required: true,
    message: '请填写手机号'
  },
  {
    pattern: /^1[3456789]\d{9}$/,
    message: '手机号格式错误'
  }
]

const passwordRules: FieldRule[] = [
  {
    required: true,
    message: '请填写密码'
  },
  {
    pattern: /^\w{8,24}$/,
    message: '密码需要8-24个字符'
  }
]

const codeRules: FieldRule[] = [
  {
    required: true,
    message: '请填写验证码'
  },
  {
    pattern: /^\d{6}$/,
    message: '验证码需要6位数字'
  }
]

//姓名校验
const nameRules: FieldRule[] = [
  { required: true, message: '请输入真实姓名' },
  { pattern: /^(?:[\u4e00-\u9fa5·]{2,16})$/, message: '姓名要求2-16个中文字符' }
]

//身份证号校验
const idCardRules: FieldRule[] = [
  { required: true, message: '身份证号不能为空' },
  {
    pattern:
      /^[1-9]\d{5}(?:18|19|20)\d{2}(?:0[1-9]|10|11|12)(?:0[1-9]|[1-2]\d|30|31)\d{3}[\dXx]$/,
    message: '请输入正确的身份证号'
  }
]

export { mobileRules, passwordRules, codeRules, nameRules, idCardRules }
